<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <input id='ipt'/>
    <button id='btn'>点我保存文本内容到根目录a.txt</button>
    <script>
        document.querySelector('#btn').addEventListener('click', ()=>{
            let val = document.querySelector("#ipt").value
            if (val) {
                // 使用node的能力
                const fs = require('fs');
                const path = require('path')
                fs.writeFile(path.join(nw.__dirname, './a.txt'), val, (err)=>{
                    if (err) {
                        throw err;
                    }
                })
            }
        })
        
       
        
    </script>
</body>
</html>